package com.woniuxy01;

import java.util.Objects;

/**
 * @author 作者
 * @create 2025-11-03 11:31
 */
public class Student{

    private int id;
    private String name;
    private int age;

    public Student() {
    }

    public Student(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        //比较对应的属性值，如果两个对象所有属性值都相同
        //当前对象和参数进行比较
        if (obj instanceof Student) {
            //如果参数是学生，转换，比较属性
            Student other = (Student) obj;
            return this.id == other.id
                    && this.name.equals(other.name)
                    && this.age == other.age;
        }
        //如果参数是学生,不是一种类型，不相等
        return false;
    }
}
